package com.example.springbootdemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ImageUploadConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        将绝对路径绑定一个相对路径（虚拟路径）
//        例如：/Users/erolaffy/IdeaProjects/SpringBootDemo/uploadImages/a.jpg可以用/images/a.jpg直接使用
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:/Users/erolaffy/IdeaProjects/SpringBootDemo/uploadImages/");
    }
}
